//
//  ZGStatisticsData.m
//  扫码
//
//  Created by 鲍志刚 on 16/4/27.
//  Copyright © 2016年 鲍志刚. All rights reserved.
//

#import "ZGStatisticsData.h"
#import "NetworkTools.h"

@implementation ZGStatisticsData

- (instancetype)initWithDict:(NSDictionary *)dict {
    
    if (self = [super init]) {
        
        [self setValuesForKeysWithDictionary:dict];
        
    }

    return self;
}


-(void)setValue:(id)value forUndefinedKey:(NSString *)key {}

+ (instancetype)statisticsDataWithDict:(NSDictionary *)dict {
    
    return [[self alloc] initWithDict:dict];
    
}

+ (void)statisticsDataWithURL:(NSString *)strUrl successBlock:(void(^)(NSDictionary *))successBlock errorBlock:(void(^)(NSError *))errorBlock {
    
    //http://192.168.0.112:8080/APP2/SweepServlet?method=getSaveCount&startTime=2016-04-01&endTime=2016-04-07
    [[NetworkTools sharedTools] GET:strUrl parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSLog(@"------------------%@",responseObject);
        
//        NSMutableDictionary *mDict = [NSMutableDictionary dictionaryWithCapacity:10];

        if (successBlock) {
            successBlock(responseObject);
        }
        
//        NSLog(@"%@",mDict.copy);

        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        if (errorBlock) {
            errorBlock(error);
        }
        
    }];
    
    
    
}

@end
